(function () {
    let template = function (self) {
        self.$uid = "switch_" + Math.random().toString(36).substring(3);
        return `<label for="${self.$uid}" class="aux-switch">
            <input id="${self.$uid}" class="weui-switch-cp__input" type="checkbox">
            <aux-view class="aux-switch__box"></aux-view>
        </label>`;
    };

    document.auiDefineElement("aux-switch", {
        template,
        props: {
            value: {
                observerProp(self) {
                    return  {
                        get() {
                            return self.$ele.input.value;
                        }
                    }
                }
            },
            checked: {
                observerProp(self) {
                    return {
                        get() {
                            return self.$ele.input.checked;
                        }
                    }               
                } 
            }
        },
        created: function(self) {
            self.$ele.root = self.children[0];
            self.$ele.input = self.$ele.root.children[0];   
        }
    });
})();


